package iserver

import (
	"src/zeus/timerwheel"
)

// ISpace 代表一个空间
type ISpace interface {
	IEntity
	ICoord
	IEntities

	GetTimeStamp() uint32

	AddEntity(entityType string, entityID uint64, dbid uint64, initParam interface{}, syncInit bool, fly bool) error
	RemoveEntity(entityID uint64) error
	RemovePlayerByDBID(dbid uint64) error

	AddTinyEntity(entityType string, entityID uint64, initParam IInitParam) (interface{}, error)
	RemoveTinyEntity(entityID uint64) error
	TravsalTinyEntity(f func(entity ISpaceEntity))
	TravsalTinyEntityUntil(f func(entity ISpaceEntity) bool)
	GetSpaceEntity(entityID uint64) ISpaceEntity
	IsMapLoaded() bool
	//FindPath(srcPos, destPos linmath.Vector3) ([]linmath.Vector3, error)
	// IsPosValid(srcPos d3.Vec3) (d3.Vec3, bool)

	GetDeltaTime() int32
	GetDeltaTimeF() float32
	//毫秒
	GetCurTime() int64
	//秒
	GetCurTimeS() int64
	GetTimer() *timerwheel.Timer

	// 转发群体消息
	BroadCastMsgRaw(srvid uint64, srvType uint8, spaceID uint64, buff []byte, entityIDs ...uint64)
	// BroadCastMsg(msg msgdef.IMsg, cb func(tar IEntity) bool)
	//GetMapInfo() interface{}
	//TravsalEntityInRange(ISpaceEntity, float32, func(ISpaceEntity))

	//把有脏数据的对象放到space里，统一在结束的时候清掉
	AddIDirty(e IDirty)
	// 设置在Loop结束的时候，需要广播发消息的方法（主要用于技能有关的RPC消息）
	SetLoopedMsg(f func())
}

// tiny对象的loop都不是每针进行的，但脏数据，需要每针进行
// 所以需要这个接口
type IDirty interface {
	//清空脏数据
	ClearDirty()
}
